package com.zhangshuo.test1.controller;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import java.util.Map;

import com.baomidou.mybatisplus.plugins.Page;
import com.zhangshuo.test1.entity.Test;
import com.zhangshuo.test1.service.ITestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Objects;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 张硕
 * @since 2017-05-31
 */
@Controller
@RequestMapping("/test1/test")
public class TestController {

    @Autowired
    private ITestService iTestService;


    @RequestMapping("/list")
    @ResponseBody
    public List<Test> getList(){
        Wrapper wrapper = new EntityWrapper();

        Page page = new Page();
        page.setCurrent(1);
        page.setSize(5);
        page = iTestService.selectPage(page, wrapper);
        return page.getRecords();

    }

    @RequestMapping("/save")
    @ResponseBody
    public Object save(Test bean){
        Map result = new HashMap<String,Object>();
        result.put("message", iTestService.insert(bean));
        return result;


    }


}
